<?php
class AppController extends Controller
{
    public $helpers    = array('Javascript', 'Html', 'Form', 'Session');
    public $components = array('Session', 'Cookie', 'MyEmail', 'Authenticate');
    public $view       = "Theme";




    public function beforeRender()
    {
        self::loadConfig();
    }

    public function send_email(array $notify, $subject, $data)
    {
        $success = true;

        foreach($notify as $v){
            $this->MyEmail->to = $v[0]['email'];
            $this->MyEmail->from = "no-reply@techsupport.com";
            $this->MyEmail->subject = $subject;
            $this->MyEmail->template = $v[0]['template'];
            $this->MyEmail->data = $data;
            if (!$this->MyEmail->send()) {
                $success = false;
                break;
            }
        }
        
        return $success;
    }


    public function loadConfig()
    {
        Configure::load('admin');
        self::set('wbtitle', Configure::read('wbtitle'));

        if ($this->Session->check('usersess')) {
            $user_info = $this->Session->read('usersess');
            $me = $user_info['User']['fname'];
        } else {
            $me = "";
        }

        self::set('me', $me);
    }

}
?>